﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Course.Models;
using Course.Views;

namespace Course.Controllers
{
    public class LogInController
    {
        public LogIn View;
        public LogInModel Model;
        public DataClasseDataContext context = new DataClasseDataContext();
        public LogInController(LogIn view) {
            Model = new LogInModel();
            this.View = view;
            this.View.Controller = this;
        }
		
		public string LogIn(){

            User user = context.User.SingleOrDefault(u => u.UserId == Model.UserId&&u.Role==Model.eRole&&u.Password==Model.Password);
            if (user==null)
            {
                return null;
            }
            else {
                Console.WriteLine(" userName:"+user.UserName);
                return user.UserId;
            }
        }
    }
}
